/* easyXDM http://easyxdm.net/ Copyright(c) 2009, �?yvind Sean Kinsey, oyvind@kinsey.no. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ window._JSON = function() { function f(n) { return n < 10 ? "0" + n : n } function thisDateToJSON(key) { return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z" : null } function thisValueOf(key) { return this.valueOf() } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {"\b":"\\b", "\t":"\\t", "\n":"\\n", "\f":"\\f", "\r":"\\r", '"':'\\"', "\\":"\\\\"}, rep; function quote(string) { escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function(a) { var c = meta[a]; return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + string + '"' } function str(key, holder) { var i, k, v, length, mind = gap, partial, value = holder[key]; if(value && typeof value === "object") { if(value instanceof Date) { value = thisDateToJSON.call(value) }else { if(value instanceof String || value instanceof Number || value instanceof Boolean) { value = thisValueOf.call(value) } } } if(typeof rep === "function") { value = rep.call(holder, key, value) } switch(typeof value) { case "string": return quote(value); case "number": return isFinite(value) ? String(value) : "null"; case "boolean": ; case "null": return String(value); case "object": if(!value) { return"null" } gap += indent; partial = []; if(Object.prototype.toString.apply(value) === "[object Array]") { length = value.length; for(i = 0;i < length;i += 1) { partial[i] = str(i, value) || "null" } v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]"; gap = mind; return v } if(rep && typeof rep === "object") { length = rep.length; for(i = 0;i < length;i += 1) { if(typeof rep[i] === "string") { k = rep[i]; v = str(k, value); if(v) { partial.push(quote(k) + (gap ? ": " : ":") + v) } } } }else { for(k in value) { if(Object.prototype.hasOwnProperty.call(value, k)) { v = str(k, value); if(v) { partial.push(quote(k) + (gap ? ": " : ":") + v) } } } } v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}"; gap = mind; return v } } return{stringify:function(value, replacer, space) { var i; gap = ""; indent = ""; if(typeof space === "number") { for(i = 0;i < space;i += 1) { indent += " " } }else { if(typeof space === "string") { indent = space } } rep = replacer; if(replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) { throw new Error("JSON.stringify"); } return str("", {"":value}) }, parse:function(text, reviver) { var j; function walk(holder, key) { var k, v, value = holder[key]; if(value && typeof value === "object") { for(k in value) { if(Object.prototype.hasOwnProperty.call(value, k)) { v = walk(value, k); if(v !== undefined) { value[k] = v }else { delete value[k] } } } } return reviver.call(holder, key, value) } text = String(text); cx.lastIndex = 0; if(cx.test(text)) { text = text.replace(cx, function(a) { return"\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) }) } if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) { j = eval("(" + text + ")"); return typeof reviver === "function" ? walk({"":j}, "") : j } throw new SyntaxError("JSON.parse"); }} }(); (function(window, document, location, setTimeout, decodeURIComponent, encodeURIComponent) { if("easyXDM" in window) { return } var global = this; var channelId = 0; var emptyFn = Function.prototype; var reURI = /^(http.?:\/\/([^\/\s]+))/; var reParent = /[\-\w]+\/\.\.\//; var reDoubleSlash = /([^:])\/\//g; var IFRAME_PREFIX = "easyXDM_"; var HAS_NAME_PROPERTY_BUG; function isHostMethod(object, property) { var t = typeof object[property]; return t == "function" || !!(t == "object" && object[property]) || t == "unknown" } function isHostObject(object, property) { return!!(typeof object[property] == "object" && object[property]) } function isArray(o) { return Object.prototype.toString.call(o) === "[object Array]" } var on, un; if(isHostMethod(window, "addEventListener")) { on = function(target, type, listener) { target.addEventListener(type, listener, false) }; un = function(target, type, listener) { target.removeEventListener(type, listener, false) } }else { if(isHostMethod(window, "attachEvent")) { on = function(object, sEvent, fpNotify) { object.attachEvent("on" + sEvent, fpNotify) }; un = function(object, sEvent, fpNotify) { object.detachEvent("on" + sEvent, fpNotify) } }else { throw new Error("Browser not supported"); } } var isReady = false, domReadyQueue = []; if("readyState" in document) { isReady = document.readyState == "complete" || document.readyState == "interactive" }else { if(document.body) { isReady = true } } function dom_onReady() { dom_onReady = emptyFn; isReady = true; for(var i = 0;i < domReadyQueue.length;i++) { domReadyQueue[i]() } domReadyQueue.length = 0 } if(!isReady) { if(isHostMethod(window, "addEventListener")) { on(document, "DOMContentLoaded", dom_onReady) }else { on(document, "readystatechange", function() { if(document.readyState == "complete") { dom_onReady() } }); if(document.documentElement.doScroll && window === top) { (function doScrollCheck() { if(isReady) { return } try { document.documentElement.doScroll("left") }catch(e) { setTimeout(doScrollCheck, 1); return } dom_onReady() })() } } on(window, "load", dom_onReady) } function whenReady(fn, scope) { if(isReady) { fn.call(scope); return } domReadyQueue.push(function() { fn.call(scope) }) } function getDomainName(url) { return url.match(reURI)[2] } function getLocation(url) { return url.match(reURI)[1] } function resolveUrl(url) { url = url.replace(reDoubleSlash, "$1/"); if(!url.match(/^(http||https):\/\//)) { var path = url.substring(0, 1) === "/" ? "" : location.pathname; if(path.substring(path.length - 1) !== "/") { path = path.substring(0, path.lastIndexOf("/") + 1) } url = location.protocol + "//" + location.host + path + url } while(reParent.test(url)) { url = url.replace(reParent, "") } return url } function appendQueryParameters(url, parameters) { var hash = "", indexOf = url.indexOf("#"); if(indexOf !== -1) { hash = url.substring(indexOf); url = url.substring(0, indexOf) } var q = []; for(var key in parameters) { if(parameters.hasOwnProperty(key)) { q.push(key + "=" + encodeURIComponent(parameters[key])) } } return url + (url.indexOf("?") === -1 ? "?" : "&") + q.join("&") + hash } var query = function() { var query = {}, pair, search = location.search.substring(1).split("&"), i = search.length; while(i--) { pair = search[i].split("="); try { query[pair[0]] = decodeURIComponent(pair[1]) }catch(e) { } } return query }(); function undef(v) { return typeof v === "undefined" } var getJSON_initTS = Math.floor(new Date / 1E3), getJSON_lastTS = getJSON_initTS, getJSON_loadedTS = 0, getJSON_useCounter = 0, getJSON_nativeIsBroken = false, getJSON_testStringify = document.location.hostname.indexOf("my.mail.ru") > -1; function getJSON() { if(window.JSON && window.JSON.stringify(["a"]) === '["a"]') { return{stringify:function() { if(getJSON_testStringify) { var now = Math.floor(new Date / 1E3); getJSON_useCounter++; getJSON_nativeIsBroken = window.JSON.stringify(["a"]) != '["a"]'; if(getJSON_nativeIsBroken) { getJSON_testStringify = false }else { if(document.readyState == "complete" && !getJSON_loadedTS) { getJSON_loadedTS = now } } getJSON_lastTS = now } return getJSON_nativeIsBroken ? window._JSON.stringify.apply(window._JSON, arguments) : window.JSON.stringify.apply(window.JSON, arguments) }, parse:function() { return window.JSON.parse.apply(window.JSON, arguments) }} }else { return window._JSON } var cached = {}; var obj = {a:[1, 2, 3]}, json = '{"a":[1,2,3]}'; if(JSON && typeof JSON.stringify === "function" && JSON.stringify(obj).replace(/\s/g, "") === json) { return JSON } if(Object.toJSON) { if(Object.toJSON(obj).replace(/\s/g, "") === json) { cached.stringify = Object.toJSON } } if(typeof String.prototype.evalJSON === "function") { obj = json.evalJSON(); if(obj.a && obj.a.length === 3 && obj.a[2] === 3) { cached.parse = function(str) { return str.evalJSON() } } } if(cached.stringify && cached.parse) { getJSON = function() { return cached }; return cached } return null } function apply(destination, source, noOverwrite) { var member; for(var prop in source) { if(source.hasOwnProperty(prop)) { if(prop in destination) { member = source[prop]; if(typeof member === "object") { apply(destination[prop], member, noOverwrite) }else { if(!noOverwrite) { destination[prop] = source[prop] } } }else { destination[prop] = source[prop] } } } return destination } function testForNamePropertyBug() { var el = document.createElement("iframe"); el.name = "easyXDM_TEST"; apply(el.style, {position:"absolute", left:"-2000px", top:"0px"}); document.body.appendChild(el); HAS_NAME_PROPERTY_BUG = !(el.contentWindow === window.frames[el.name]); document.body.removeChild(el) } function createFrame(config) { if(undef(HAS_NAME_PROPERTY_BUG)) { testForNamePropertyBug() } var frame; if(HAS_NAME_PROPERTY_BUG) { frame = document.createElement('